<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title></title>
    @include('common-css')
    <style>

        .input_box {
            width: 100%;
            height: 40px;
            margin-top: 15px;
            margin-bottom: 15px;
            display: flex;
            justify-content: flex-start;
            align-items: center;
        }

        .input_label {
            width: 120px;
            box-sizing: border-box;
        }

        .project-table {
            margin-top: 15px;
        }

        .status-tag {
            color: #1890ff;
            border: 1px solid #91d5ff;
            border-radius: 3px;
            background: #e6f7ff;
            font-size: 12px;
            padding: 2px 3px;
        }

        .ant-table-tbody > tr > td, .ant-table-thead > tr > th {
            vertical-align: middle;
            line-height: 25px;
        }

        .search_box {
            width: 1000px;
        }

        .search_box input {
            width: 300px;
        }

        .search_box button {
            margin-left: 20px;
        }

        .search_box .ant-select {
            margin-left: 20px;
        }

        .expert-table {
            width: 100%;
            border-collapse: collapse;
            text-align: left;
            border-radius: 4px 4px 0 0;
        }

        .expert-table > tr > th {
            vertical-align: middle;
            line-height: 25px;
            padding: 16px;
            background: #fafafa;
            -webkit-transition: background .3s ease;
            transition: background .3s ease;
            text-align: center;
            color: rgba(0, 0, 0, .85);
            font-weight: 500;
            border-bottom: 1px solid #e8e8e8;
        }

        .expert-table > tr > td {
            padding: 8px;
            line-height: 25px;
            vertical-align: middle;
            text-align: center;
        }

        .inner-table {
            width: 100%;
            border-collapse: collapse;
        }

        .inner-table th {
            font-weight: bold;
            color: #888;
            padding: 6px 3px;
            text-align: center;
            border: 1px solid #eee;
            vertical-align: middle;
            font-size: 12px;
        }

        .inner-table td {
            border: 1px solid #eee;
            padding: 6px 3px;
            text-align: center;
            vertical-align: middle;
            font-size: 14px;
        }

        .delete-btn-a {
            color: #f5222d
        }

    </style>
</head>
<body>

<div id="app"></div>

<script id="appTemplate" type="x-template">
    <a-locale-provider :locale="antdLocale">
        <div class="container">

            @include('admin.header-tpl')

            <main>
                <div class="common_container">

                    @include('admin.aside-tpl')

                    <div class="common_content admin_common_content">

                        <a-tabs defaultActiveKey="reviewer_groups"
                                type="card"
                                @change="tableChange">

                            <a-tab-pane tab="评审专家小组" key="reviewer_groups">
                                <div v-if="true" style="margin-bottom: 20px">

                                    @php
                                        // $AutoCreate   自动组建一个专家组
                                        // $AutoAssign   自动分配所有项目到专家组
                                        // $SubmitReview 提交已分配项目至专家评审
                                        // $DeleteGroup  删除专家组
                                        $large_group_id = $_GET['large_group_id'];
                                        switch ($large_group_id){
                                            case 1:
                                                //路基路面组
                                                $AutoCreate = isset($userMenusKeyData[64]) ? true : false;
                                                $AutoAssign = isset($userMenusKeyData[65]) ? true : false;
                                                $SubmitReview = isset($userMenusKeyData[66]) ? true : false;
                                                $DeleteGroup = isset($userMenusKeyData[76]) ? true : false;
                                                break;
                                            case 2:
                                                //桥涵组
                                                $AutoCreate = isset($userMenusKeyData[67]) ? true : false;
                                                $AutoAssign = isset($userMenusKeyData[68]) ? true : false;
                                                $SubmitReview = isset($userMenusKeyData[69]) ? true : false;
                                                $DeleteGroup = isset($userMenusKeyData[77]) ? true : false;
                                                break;
                                            case 3:
                                                //隧道及地下工程组
                                                $AutoCreate = isset($userMenusKeyData[70]) ? true : false;
                                                $AutoAssign = isset($userMenusKeyData[71]) ? true : false;
                                                $SubmitReview = isset($userMenusKeyData[72]) ? true : false;
                                                $DeleteGroup = isset($userMenusKeyData[78]) ? true : false;
                                                break;
                                            case 4:
                                                //综合组
                                                $AutoCreate = isset($userMenusKeyData[73]) ? true : false;
                                                $AutoAssign = isset($userMenusKeyData[74]) ? true : false;
                                                $SubmitReview = isset($userMenusKeyData[75]) ? true : false;
                                                $DeleteGroup = isset($userMenusKeyData[79]) ? true : false;
                                                break;
                                        }

                                    @endphp

                                    @if($AutoCreate)
                                        <a-button :disabled="notAtPhaseAssignReview" type="primary"
                                                  @click="handleCreateReviewerGroup">自动组建一个专家组
                                        </a-button>
                                    @endif

                                    @if($AutoCreate)
                                        <a-button style="margin-left: 8px;" type="primary" @click="handleAssignProjects"
                                                  :disabled='notAtPhaseAssignReview'>
                                            自动分配所有项目到专家组
                                        </a-button>
                                    @endif

                                    <a-button v-if="false" style="margin-left: 8px;" :disabled="notAtPhaseAssignReview"
                                              @click="handleCancelAssignProjects">
                                        取消分配项目
                                    </a-button>

                                    @if($AutoCreate)
                                        <a-button style="margin-left: 8px;" type="primary"
                                                  :disabled='notAtPhaseAssignReview'
                                                  @click="confirmSubmitAssignProjectsDialogVisible = true">
                                            提交已分配项目至专家评审
                                        </a-button>
                                @endif

                                <!--@time 2020-06-15-->
                                    <!--@time 2020-06-15-->
                                    <!--@time 2020-06-15-->
                                {{--                                    <a-button type="primary"--}}
                                {{--                                              @click="showExcelDialog('导出专家组信息','assign_review')"--}}
                                {{--                                              style="margin-left: 12px">--}}
                                {{--                                        导出专家组信息--}}
                                {{--                                    </a-button>--}}
                                <!--@time 2020-06-15-->
                                    <!--@time 2020-06-15-->
                                    <!--@time 2020-06-15-->
                                </div>

                                <div style="font-size: smaller; color: grey">
                                    <p>符合下列条件的专家才可能成为该大组的网评候选专家: (1)未被排除出网评候选专家；(2)专家的『联系电话』、『职位』、『工作单位』3 项信息填写完整；(3)专家的『专业领域』与该大组的专业领域匹配</p>
                                    <p>可在【系统管理】>【评审专家管理】页面管理评审专家</p>
                                </div>

                                <div style="margin-top: 10px; margin-bottom: 20px;">
                                    共 <span style="color: red;">@{{ reviewerGroupPageData.length }}</span>
                                    个专家组，平均每个专家组分配约 <span style="color: red;">@{{ avgProjectsPerReviewerGroup }}</span>
                                    个项目。
                                    <template v-if="cannotAttendReviewersCount">
                                        尚有 <span style="color: red;">@{{ cannotAttendReviewersCount }}</span> 名专家不能参加评审。
                                    </template>
                                    已分配 <span style="color: red;">@{{ assignedProjectCount }}</span> 个项目。
                                </div>

                                <a-table v-if="true"
                                         class="reviewer-group-table"
                                         rowKey="id"
                                         size="small"
                                         :columns="reviewerGroupTableColumns"
                                         :dataSource="filteredReviewerGroups"
                                         :loading="loadingReviewerGroupPageData"
                                         :pagination="{pageSize: 10000, hideOnSinglePage: true, position: 'both', showTotal: total => `共 ${total} 项`}">
                                <span slot="keywordsTitle">
                                    回避关键词
                                    <a-tooltip>
                                        <template slot="title">
                                            自动分配所有项目到专家组时，若某项目的『申报者名称』或『申报者的工作单位名称』中，含有某专家组的『回避关键词』中的任意一个，则该项目不会被分配到该专家组
                                        </template>
                                        <a-icon type="info-circle"/>
                                    </a-tooltip>
                                    </span>
                                    <span slot="reviewers" size="large" slot-scope="text, record">

                                        <a-table class="reviewer-group-reviewers-table"
                                                 rowKey="id"
                                                 size="small"
                                                 :columns="reviewerGroupReviewersTableColumns"
                                                 :dataSource="record.reviewers"
                                                 bordered
                                                 :loading="false"
                                                 :pagination="{pageSize: 10000, hideOnSinglePage: true, position: 'both', showTotal: total => `共 ${total} 项`}">
                                            <p slot="reviewer" slot-scope="text, reviewer" style="text-align: left;">
                                                @{{ reviewer.name + ' / ' + reviewer.prof_title + ' / ' + reviewer.tel }}<br>
                                                @{{ reviewer.work_org_name }}<br>
                                                账号: @{{ reviewer.username }},@{{ reviewer.password }}
                                            </p>
                                            <span slot="can_attend_review" slot-scope="text, reviewer">
                                                <template>
                                                    <a-radio-group size="small" :disabled="notAtPhaseAssignReview"
                                                                   v-model="reviewer.can_attend_review"
                                                                   @change="updateReviewerCanAttendReview(reviewer)">
                                                        <a-radio :value="1">能</a-radio>
                                                        <a-radio :value="0">不能</a-radio>
                                                    </a-radio-group><br>
                                                    <a v-if="!reviewer.can_attend_review"
                                                       :disabled="notAtPhaseAssignReview"
                                                       @click="autoReplaceReviewer(reviewer)">自动挑选专家</a><br>
                                                    <a v-if="!reviewer.can_attend_review"
                                                       :disabled="notAtPhaseAssignReview"
                                                       @click="handleManualSelectReviewer(reviewer)">指定专家</a>
                                                </template>
                                            </span>
                                        </a-table>
                                    </span>

                                    <span slot="keywords" size="large" slot-scope="text, record">
                                        <p style="margin-bottom: 8px;">关键词之间用逗号分隔</p>
                                        <a-textarea
                                                :disabled="notAtPhaseAssignReview"
                                                v-model='record.keywords' :autosize="{minRows: 8, maxRows: 20}"
                                                    @focus="handleReviewerGroupKeywordsFocus(record)"
                                                    @blur="handleReviewerGroupKeywordsBlur(record)"/>
                                    </span>
                                    <span slot="project_count" size="large" slot-scope="text, record">
                                        <a-button
                                                @click="showReviewerGroupProjects(record)">@{{ record.project_count }}
                                        </a-button>
                                    </span>
                                    <span slot="operations" slot-scope="text, record">
                                        @if($DeleteGroup)
                                            <a-popconfirm v-if="!notAtPhaseAssignReview" title="确认删除该专家组？"
                                                          okText="是" cancelText="否"
                                                          @confirm="handleDeleteReviewerGroup(record)">
                                            <a class="delete-btn-a">删除</a>
                                        </a-popconfirm>
                                            <a v-else class="delete-btn-a" :disabled='true'>删除</a>
                                        @endif
                                    </span>
                                </a-table>
                            </a-tab-pane>

                            <a-tab-pane tab="项目列表" key="projects">
                                @include('admin.table-projects')
                            </a-tab-pane>
                        </a-tabs>

                    </div>

                </div>
            </main>

            <a-modal
                    title="退回原因"
                    v-model="dialogRecallReasonVisible"
                    @ok="handleRecallReasonDialogOk"
                    @cancel="">
                <a-textarea v-model="recallReason" placeholder="请填写退回原因" :rows="4"></a-textarea>
            </a-modal>

            <a-modal :width="1000" v-model="viewReviewerGroupProjectsDialogVisible"
                     title="查看项目" @ok="viewReviewerGroupProjectsDialogVisible = false">
                <div>
                    <div style="margin-bottom: 15px">共有 @{{ viewingReviewerGroupProjects.length }}
                        条项目
                    </div>
                    <a-table class="view-reviewer-group-projects-table"
                             rowKey="id"
                             size="small"
                             :columns="viewReviewerGroupProjectsTableColumns"
                             :dataSource="viewingReviewerGroupProjects"
                             :loading="false"
                             :pagination="{pageSize: 10000, hideOnSinglePage: true, position: 'both', showTotal: total => `共 ${total} 项`}">
                    </a-table>
                </div>
            </a-modal>

            <a-modal :width="300" v-model="confirmSubmitAssignProjectsDialogVisible"
                     title="确认提交给专家评审？" @ok="handleConfirmSubmitAssignProjects">
                提交给专家评审后，不能重新分配项目，确认提交？
            </a-modal>

            <a-modal :width="1000" v-model="selectReviewerDialogVisible"
                     title="指定专家" @ok="selectReviewerDialogVisible = false">
                <div style="display: flex; position: relative; margin-bottom: 10px; align-items: center;">
                    <span style="flex: 1;"></span>
                    <a-input style="width: 300px;" placeholder="搜索" v-model="selectReviewerDialogSearchKeyword"/>
                    <a-icon v-if="selectReviewerDialogSearchKeyword"
                            style="position: absolute; top: 8px; right: 8px; color: #aaa; cursor: pointer;"
                            type="cross"
                            @click="selectReviewerDialogSearchKeyword = ''"/>
                </div>

                <a-table class="reviewer-table"
                         rowKey="id"
                         size="small"
                         :columns="candidateReviewerTableColumns"
                         :dataSource="filteredCandidateReviewers"
                         :loading="loadingCandidateReviewers"
                         :pagination="{pageSize: 10000, hideOnSinglePage: true, position: 'both', showTotal: total => `共 ${total} 项`}">

                    <span slot="prof_fields" slot-scope="text, record">
                        @{{ record.prof_fields }}
                    </span>
                    <span slot="operations" slot-scope="text, record">
                        <a @click="replaceReviewer(oldReviewerId, record.id)">选择</a>
                    </span>

                </a-table>
            </a-modal>

            @include('admin.excel-export-tpl')
        </div>
    </a-locale-provider>
</script>
@include('admin.excel-export-js')
@include('common-js')

@include('admin.header-js')
@include('admin.aside-js')

<script>
    var queryParams = parseUrl(location.href).params;

    var projectTableColumns = [
        {
            width: 60,
            title: '序号',
            dataIndex: 'num'
        },
        {
            width: 150,
            title: '项目名称',
            dataIndex: 'project_name',
            scopedSlots: {
                customRender: 'project_name'
            }
        },
            @if (Request::get('award_id') == '1')
        {
            width: 100,
            title: '专业类别',
            dataIndex: 'prof_category',
            scopedSlots: {
                customRender: 'prof_category'
            }
        },
            @endif
        {
            width: 180,
            title: '申报者',
            dataIndex: 'applicant',
            scopedSlots: {
                customRender: 'applicant'
            }
        }, {
            width: 70,
            title: '申报书',
            dataIndex: 'application_form',
            scopedSlots: {
                customRender: 'application_form'
            }
        }, {
            width: 70,
            title: '附件',
            dataIndex: 'attachments',
            scopedSlots: {
                customRender: 'attachments'
            }
        }, {
            width: 120,
            title: '状态',
            dataIndex: 'status',
            scopedSlots: {
                customRender: 'status'
            }
        },
            @if (false)
        {
            width: 100,
            title: '待办事项',
            dataIndex: 'applicant_todo',
            scopedSlots: {
                customRender: 'todo'
            }
        },
            @endif
        {
            width: 100,
            title: '操作',
            key: 'operations',
            scopedSlots: {
                customRender: 'operations'
            }
        }
    ];

    var reviewerGroupTableColumns = [
        {
            width: 50,
            title: '序号',
            dataIndex: 'num'
        },
        {
            width: 100,
            title: '小组名称',
            dataIndex: 'name'
        },
        {
            width: 200,
            align: 'center',
            title: '组内专家',
            dataIndex: 'reviewers',
            scopedSlots: {
                customRender: 'reviewers'
            }
        },
        {
            width: 100,
            slots: {
                title: 'keywordsTitle'
            },
            dataIndex: 'keywords',
            scopedSlots: {
                customRender: 'keywords'
            }
        },
        {
            width: 80,
            title: '项目数量',
            dataIndex: 'project_count',
            scopedSlots: {
                customRender: 'project_count'
            }
        },
        {
            width: 80,
            title: '操作',
            key: 'operations',
            scopedSlots: {
                customRender: 'operations'
            }
        }
    ];

    var viewReviewerGroupProjectsTableColumns = [
        {
            width: 60,
            title: '序号',
            dataIndex: 'num'
        },
        {
            width: 80,
            title: '奖项类型',
            dataIndex: 'award_name'
        },
        {
            width: 400,
            title: '项目名称',
            dataIndex: 'project_name'
        },
        {
            width: 200,
            title: '申报者',
            dataIndex: 'applicant_name',
        },
    ];

    var reviewerGroupReviewersTableColumns = [
        {
            width: 60,
            title: '序号',
            dataIndex: 'reviewer_order'
        },
        {
            width: 350,
            align: 'center',
            title: '专家',
            key: 'reviewer',
            scopedSlots: {
                customRender: 'reviewer'
            }
        },
        {
            width: 150,
            title: '能否参加评审',
            dataIndex: 'can_attend_review',
            scopedSlots: {
                customRender: 'can_attend_review'
            }
        },
    ];

    var candidateReviewerTableColumns = [
        {
            width: 60,
            title: '序号',
            dataIndex: 'num'
        },
        {
            width: 100,
            title: '姓名',
            dataIndex: 'name',
        },
        {
            width: 200,
            title: '单位',
            dataIndex: 'work_org_name',
        },
        {
            width: 100,
            title: '职务',
            dataIndex: 'prof_title',
        },
        {
            width: 150,
            title: '联系方式',
            dataIndex: 'tel',
        },
        {
            width: 200,
            title: '评审专业',
            dataIndex: 'prof_fields',
            scopedSlots: {
                customRender: 'prof_fields'
            }
        },
        {
            width: 150,
            title: '操作',
            dataIndex: 'operations',
            scopedSlots: {
                customRender: 'operations'
            }
        },
    ];

    var awardsInfo = {!! json_encode(array_values(config('vars.awards')), JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT) !!};

</script>

<script>
    var app = new Vue({
        el: '#app',
        template: '#appTemplate',
        data: {
            profCategoryFilter: '',
            searchKeyword: '',

            projectTableColumns,
            projectPageData: [],
            loadingPageData: false,

            //@start excel export
            ExcelExportParam: {
                type: 'assign_review',
                large_group_id: queryParams.large_group_id,
                award_id: queryParams.award_id,
                status_ids: queryParams.status_ids
            },
            //@end excel export

            dialogRecallReasonVisible: false,
            recallingProject: {},
            recallReason: '',

            reviewerGroupTableColumns,
            reviewerGroupPageData: [],
            loadingReviewerGroupPageData: false,
            confirmSubmitAssignProjectsDialogVisible: false,
            editingReviewerGroupKeywords: '',
            viewReviewerGroupProjectsDialogVisible: false,
            viewingReviewerGroupProjects: [],
            viewReviewerGroupProjectsTableColumns,

            reviewerGroupReviewersTableColumns,

            selectReviewerDialogVisible: false,
            selectReviewerDialogSearchKeyword: '',
            candidateReviewerTableColumns,
            candidateReviewers: [],
            loadingCandidateReviewers: false,
            oldReviewerId: null,

            queryParams,
            awardsInfo,
            profCategories,

            asideSelectedKeys: [queryParams.aside_key],
            antdLocale: antd.locales.zh_CN,
            ...AdminHeader.data,
            ...AdminAside.data,
            ...Workflow.data,
            ...ExcelExport.data
        },
        computed: {
            avgProjectsPerReviewerGroup() {
                let projectCount = this.notAtPhaseAssignReview ? this.assignedProjectCount : this.projectPageData.length
                let reviewerGroupCount = this.reviewerGroupPageData.length
                if (reviewerGroupCount == 0) {
                    return 0
                }
                return Math.floor(projectCount / reviewerGroupCount)
            },
            cannotAttendReviewersCount() {
                var count = 0;
                this.reviewerGroupPageData.forEach(reviewerGroup => {
                    reviewerGroup.reviewers.forEach(reviewer => {
                        if (!reviewer.can_attend_review) {
                            count += 1
                        }
                    })
                });
                return count
            },
            assignedProjectCount() {
                return this.reviewerGroupPageData.reduce((sum, reviewerGroup) => sum + reviewerGroup.project_count, 0)
            },
            filteredProjects() {
                var projects = this.searchFilteredProjects;
                if (this.profCategoryFilter) {
                    projects = projects.filter(project => {
                        return project.prof_category == this.profCategoryFilter
                    })
                }
                var num = 1;
                projects.forEach(project => {
                    project.num = num++
                });
                return projects
            },
            searchFilteredProjects() {
                var projects;
                if (this.searchKeyword) {
                    var q = this.searchKeyword.trim();
                    projects = this.projectPageData.filter(project => {
                        var text = project.project_name + project.applicant_name + project.applicant_org_name + project.applicant_tel + project.applicant_email;
                        return text.toLowerCase().indexOf(q) != -1
                    })
                } else {
                    projects = this.projectPageData
                }
                return projects
            },

            filteredReviewerGroups() {
                this.reviewerGroupPageData.forEach((reviewerGroup, index) => {
                    this.$set(this.reviewerGroupPageData[index], 'num', index + 1)
                });
                return this.reviewerGroupPageData;
            },

            filteredCandidateReviewers() {
                let reviewers = this.filteredCandidateReviewersBySearch
                var num = 1;
                reviewers.forEach(reviewer => {
                    reviewer.num = num++
                });
                return reviewers
            },

            filteredCandidateReviewersBySearch() {
                var reviewers;
                if (this.selectReviewerDialogSearchKeyword) {
                    var q = this.selectReviewerDialogSearchKeyword.trim();
                    reviewers = this.candidateReviewers.filter(reviewer => {
                        var text = reviewer.name + reviewer.work_org_name + reviewer.prof_title + reviewer.tel + reviewer.prof_fields;
                        return text.toLowerCase().indexOf(q) != -1
                    })
                } else {
                    reviewers = this.candidateReviewers
                }
                return reviewers
            },

            notAtPhaseAssignReview() {
                return this.notAtPhases(['C'], queryParams.large_group_id)
            }
        },
        beforeMount() {
            this.loadAsideDefaultOpenKeys()
        },
        mounted() {
            this.reloadPageData();
            this.reloadAsideData();
            this.reloadWorkflowPhases()
        },
        methods: {
            countProjectsByProfCategory(category) {
                var projects = this.searchFilteredProjects;
                if (category == '') {
                    return projects.length
                }
                var count = 0;
                projects.forEach(project => {
                    if (project.prof_category == category) {
                        count += 1
                    }
                });
                return count
            },
            handleProfCategoryChange(record, value) {
                console.log('handleProfCategoryChange', record, value);
                axios.post('/api/admin/update-project-attrs', {
                    project_id: record.id,
                    attrs: {
                        prof_category: value
                    }
                }).then(response => {
                    success('修改成功')
                })
            },

            getProjectsPromise() {
                return axios.get('/api/admin/get-projects', {
                    params: {
                        award_id: queryParams.award_id,
                        status_ids: queryParams.status_ids,
                        large_group_id: queryParams.large_group_id,
                    }
                })
            },
            getReviewerGroupsPromise() {
                return axios.get('/api/admin/get-reviewer-groups', {
                    params: {
                        large_group_id: queryParams.large_group_id,
                    }
                })
            },
            reloadPageData() {
                this.loadingPageData = true;
                this.loadingReviewerGroupPageData = true;
                axios.all([this.getProjectsPromise(), this.getReviewerGroupsPromise()]).then(
                    axios.spread((respProjects, respReviewerGroups) => {
                        this.projectPageData = respProjects.data;
                        if (respReviewerGroups.data.ok) {
                            this.reviewerGroupPageData = respReviewerGroups.data.reviewer_groups
                        } else {
                            error('加载 评审专家小组 数据失败');
                            this.reviewerGroupPageData = []
                        }
                        this.loadingPageData = false;
                        this.loadingReviewerGroupPageData = false
                    })
                )
            },
            reloadReviewerGroupPageData() {
                this.loadingReviewerGroupPageData = true;
                this.getReviewerGroupsPromise().then(response => {
                    if (response.data.ok) {
                        this.reviewerGroupPageData = response.data.reviewer_groups
                    } else {
                        this.reviewerGroupPageData = []
                    }
                    this.loadingReviewerGroupPageData = false
                })
            },
            showRecallReasonDialog(project) {
                this.recallingProject = project;
                this.recallReason = '';
                this.dialogRecallReasonVisible = true
            },
            handleRecallReasonDialogOk() {
                if (this.recallReason == '') {
                    warn('退回原因不能为空');
                    return
                }
                this.updateProjectStatus(this.recallingProject, 'B1.2', this.recallReason);
                this.dialogRecallReasonVisible = false
            },
            updateProjectStatus(project, statusId, statusRemarks) {
                console.log('updateProjectStatus', project, statusId, statusRemarks);
                loading('正在处理，请稍候');
                var postData = {
                    project_id: project.id,
                    status_id: statusId,
                };
                if (statusRemarks) {
                    postData.status_remarks = statusRemarks
                }
                axios.post('/api/admin/update-project-status', postData)
                    .then(response => {
                        dismiss();
                        success('操作成功');
                        this.reloadPageData();
                        this.reloadAsideData()
                    })
            },
            findAwardInfoById(id) {
                return this.awardsInfo.filter(item => {
                    return item.id == id
                })[0]
            },

            handleCreateReviewerGroup() {
                axios.post('/api/admin/create-reviewer-group', {
                    'large_group_id': queryParams.large_group_id
                }).then(response => {
                    if (response.data.ok) {
                        success('成功组建了一个专家组');
                        this.reloadReviewerGroupPageData()
                    } else {
                        error('组建专家组失败: ' + response.data.msg)
                    }
                })
            },
            handleAssignProjects() {
                axios.post('/api/admin/assign-projects', {
                    'large_group_id': queryParams.large_group_id
                }).then(response => {
                    if (response.data.ok) {
                        success('分配项目成功');
                        this.reloadPageData()
                    } else {
                        error('分配项目失败: ' + response.data.msg)
                    }
                })
            },
            handleCancelAssignProjects() {
                axios.post('/api/admin/cancel-assign-projects', {
                    'large_group_id': queryParams.large_group_id
                }).then(response => {
                    if (response.data.ok) {
                        success('取消分配项目成功');
                        this.reloadPageData()
                    } else {
                        error('取消分配项目失败: ' + response.data.msg)
                    }
                })
            },
            handleConfirmSubmitAssignProjects() {
                axios.post('/api/admin/submit-assign-projects', {
                    'large_group_id': queryParams.large_group_id
                }).then(response => {
                    if (response.data.ok) {
                        success('提交给专家评审成功');
                        this.reloadPageData();
                        this.reloadAsideData();
                        this.reloadWorkflowPhases()
                    } else {
                        error('提交给专家评审失败: ' + response.data.msg)
                    }
                });
                this.confirmSubmitAssignProjectsDialogVisible = false
            },

            updateReviewerCanAttendReview(reviewer) {
                axios.post('/api/admin/update-reviewer-can-attend-review', {
                    'reviewer_id': reviewer.reviewer_id,
                    'can_attend_review': reviewer.can_attend_review,
                }).then(response => {
                    if (response.data.ok) {
                        success('专家能否参加评审修改成功')
                    } else {
                        error('专家能否参加评审修改失败: ' + response.data.msg)
                    }
                })
            },
            autoReplaceReviewer(reviewer) {
                axios.post('/api/admin/auto-replace-reviewer', {
                    'reviewer_id': reviewer.reviewer_id
                }).then(response => {
                    if (response.data.ok) {
                        success('自动挑选专家成功');
                        this.reloadReviewerGroupPageData()
                    } else {
                        error('自动挑选专家失败: ' + response.data.msg)
                    }
                })
            },
            handleReviewerGroupKeywordsFocus(reviewerGroup) {
                this.editingReviewerGroupKeywords = reviewerGroup.keywords;
            },
            handleReviewerGroupKeywordsBlur(reviewerGroup) {
                if (reviewerGroup.keywords !== this.editingReviewerGroupKeywords) {
                    axios.put('/api/admin/update-reviewer-group-keywords', {
                        reviewer_group_id: reviewerGroup.id,
                        keywords: reviewerGroup.keywords,
                    }).then(response => {
                        if (response.data.ok) {
                            success('回避关键词修改成功')
                        } else {
                            error('回避关键词修改失败')
                        }
                    })
                }
                this.editingReviewerGroupKeywords = ''
            },
            showReviewerGroupProjects(reviewerGroup) {
                console.log('showReviewerGroupProjects', reviewerGroup);
                this.viewingReviewerGroupProjects = reviewerGroup.projects;
                this.viewingReviewerGroupProjects.forEach((project, index) => project.num = index + 1);
                this.viewReviewerGroupProjectsDialogVisible = true
            },
            handleDeleteReviewerGroup(reviewerGroup) {
                axios.post('/api/admin/delete-reviewer-group', {
                    reviewer_group_id: reviewerGroup.id,
                }).then(response => {
                    if (response.data.ok) {
                        success('删除成功');
                        this.reloadPageData()
                    } else {
                        error('删除失败: ' + response.data.msg)
                    }
                })
            },
            handleManualSelectReviewer(oldReviewer) {
                this.oldReviewerId = oldReviewer.reviewer_id
                this.selectReviewerDialogVisible = true
                this.reloadCandidateReviewers()
            },
            reloadCandidateReviewers() {
                this.loadingCandidateReviewers = true
                axios.get('/api/admin/get-candidate-reviewers', {
                    params: {
                        large_group_id: queryParams.large_group_id,
                    }
                }).then(response => {
                    let data = response.data
                    if (data.ok) {
                        this.candidateReviewers = data.candidateReviewers
                    } else {
                        error('加载候选评审专家失败: ' + data.msg)
                    }
                    this.loadingCandidateReviewers = false
                })
            },
            replaceReviewer(oldReviewerId, newReviewerId) {
                this.selectReviewerDialogVisible = false
                axios.post('/api/admin/replace-reviewer', {
                    old_reviewer_id: oldReviewerId,
                    new_reviewer_id: newReviewerId,
                }).then(response => {
                    let data = response.data
                    if (data.ok) {
                        success('指定专家成功')
                        this.reloadReviewerGroupPageData()
                    } else {
                        error('指定专家失败: ' + data.msg)
                    }
                })
            },


            tableChange(key) {
                if (key == 'projects') {
                    this.ExcelExportParam.type = 'list_project'
                } else {
                    this.ExcelExportParam.type = 'assign_review'
                }
            },

            ...AdminHeader.methods,
            ...AdminAside.methods,
            ...Workflow.methods,
            ...ExcelExport.methods
        }
    })
</script>

</body>
</html>